package com.wk1un2.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wk1un2.entity.Product;
import com.wk1un2.mapper.ProductMapper;
import com.wk1un2.service.ProductService;
import com.wk1un2.util.Result;

/**
 * 业务接口的实现类
 * 
 * @author Administrator
 *
 */
@Service // 扫描
public class ProductServiceImpl implements ProductService {

	@Autowired
	private ProductMapper ProductMapper;// 自动注入mapper

	@Override
	public List<Product> getAll(int page, int limit, String p_name, Integer p_state) {
		// TODO Auto-generated method stub
		return ProductMapper.getAll(page, limit, p_name, p_state);
	}

	@Override
	public Integer count() {
		// TODO Auto-generated method stub
		return ProductMapper.count();
	}

	@Override
	public Integer add(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return ProductMapper.add(map);
	}

	@Override
	public Integer update(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return ProductMapper.update(map);
	}

	@Override
	public Integer delete(int p_id) {
		// TODO Auto-generated method stub
		return ProductMapper.delete(p_id);
	}

	@Override
	public Result updateproductstate(Integer p_id, Integer p_state) {
		// TODO Auto-generated method stub
		ProductMapper.updateproductstate(p_id, p_state);
		return Result.ok(1);

	}

	@Override
	public List<Map<String, Object>> getProduct(Integer p_id) {
		// TODO Auto-generated method stub
		return ProductMapper.getProduct(p_id);
	}

}
